package com.hitqz.robot.biz.schedule;

import com.hitqz.robot.api.business.enums.NavEnum;
import com.hitqz.robot.biz.service.RobotService;
import com.hitqz.robot.driver.model.IRobotPosDto;
import com.hitqz.robot.driver.parent.RobotDriverService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author xupkun
 * @date 2025/4/9
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class CheckNavStatusSchedule {

    private final RobotService robotService;

    private final RobotDriverService robotDriverService;

    public static Integer navStatus = 0;

//    @Scheduled(fixedRate = 1000)
    public void rodRobotController() {
        // 有任务
        IRobotPosDto posDto = robotDriverService.getWebPos();
        if (navStatus == 1) {
            if (posDto.getTaskStatus() == NavEnum.SUSPENDED.getCode()) {
                log.info("任务执行中 突然暂停直接继续");
                robotDriverService.navCmd(NavEnum.RUNNING.getCode());
            } else {
                // 复原
                navStatus = 0;
            }
        }
    }


}
